package com.csair.seam.infrastructure.config;

import java.util.Properties;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;

/**
 * @Author: wurunbin
 * @Date: 2020/3/5 14:22
 * @Description:
 **/
@Configuration
@MapperScan("com.csair.seam.domain.mapper")
@EnableTransactionManagement
public class MybatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
    	MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
    	
    	PaginationInnerInterceptor pageInterceptor = new PaginationInnerInterceptor();
    	pageInterceptor.setDbType(DbType.ORACLE);
    	pageInterceptor.setOverflow(true);
    	
    	mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
    	mybatisPlusInterceptor.addInnerInterceptor(pageInterceptor);
    	return mybatisPlusInterceptor;
    }
    
    @Bean
    public ConfigurationCustomizer configurationCustomizer(){
        return mybatisConfiguration -> mybatisConfiguration.setUseGeneratedShortKey(false);
    }

}
